namespace Xsxiaosa.Net
{
    using System;
    using System.IO;

    internal class FtpWebStream : Stream
    {
        // Methods
        public FtpWebStream(Stream stream)
        {
            this._stream = stream;
        }

        public override void Close()
        {
            try
            {
                this._stream.Close();
            }
            catch (FtpException exception1)
            {
                throw exception1.ToWebException();
            }
        }

        public override void Flush()
        {
            this._stream.Flush();
        }

        public override int Read(byte[] buffer, int offset, int count)
        {
 //jyj modify           int num1;
            try
            {
                return this._stream.Read(buffer, offset, count);
            }
            catch (FtpException exception1)
            {
                throw exception1.ToWebException();
            }
 //jyj modify           return num1;
        }

        public override long Seek(long offset, SeekOrigin origin)
        {
            return this._stream.Seek(offset, origin);
        }

        public override void SetLength(long length)
        {
            this._stream.SetLength(length);
        }

        public override void Write(byte[] buffer, int offset, int count)
        {
            try
            {
                this._stream.Write(buffer, offset, count);
            }
            catch (FtpException exception1)
            {
                throw exception1.ToWebException();
            }
        }


        // Properties
        public override bool CanRead
        {
            get
            {
                return this._stream.CanRead;
            }
        }

        public override bool CanSeek
        {
            get
            {
                return this._stream.CanSeek;
            }
        }

        public override bool CanWrite
        {
            get
            {
                return this._stream.CanWrite;
            }
        }

        public override long Length
        {
            get
            {
                return this._stream.Length;
            }
        }

        public override long Position
        {
            get
            {
                return this._stream.Position;
            }
            set
            {
                this._stream.Position = value;
            }
        }


        // Fields
        private Stream _stream;
    }}

